I have Problem by initializing a choice box:
Skip sl_exportviews = GetViewsOfModule(m) put(sl_exportviews, USE_CURRENT_VIEW_CONFIG, "")
string s_exportviews[] s_exportviews = ConvertSkipListKeysToStringArray(sl_exportviews)
delete sl_exportviews
int i_no_of_views = sizeof(s_exportviews) Line xx: viewChoiceDBE = choice(exportBox_, LabelExportView, s_exportviews, i_no_of_views, 0, 40, false) //drop down selector viewChoiceDBE->"left"->"inside"->tabStrip;.
At line 11 I get following error: -R-E- DXL: < Line xx:Invalid number of items: 11, maximum is 0 -I- DXL: execution halted.
Does anybody know why this happens? The passed string-array s_exportviews has valid elements (tested and verified). MarcoLuk - Tue Jul 25 10:02:28 EDT 2017 |
Re: Problem with choice-box: "Invalid number of items: .." - where is the string array defined? - where are the strings (I asume the name of the view) stored? - what does 'ConvertSkipListKeysToStringArray()' realy return? An string array, a pointer to a string array?
My assumption is: the string array lives on the call-stack. 'sizeof()'' gives you the size of the array on the stack. Calling 'choice' overwrites the string array on the stack and therefore the call crashes. |
Re: Problem with choice-box: "Invalid number of items: .." thsturm - Wed Jul 26 03:20:58 EDT 2017 - where is the string array defined? - where are the strings (I asume the name of the view) stored? - what does 'ConvertSkipListKeysToStringArray()' realy return? An string array, a pointer to a string array?
My assumption is: the string array lives on the call-stack. 'sizeof()'' gives you the size of the array on the stack. Calling 'choice' overwrites the string array on the stack and therefore the call crashes. Hello thsturm,
thank you very much for your helpful answer! Indeed the function "ConvertSkipListKeysToStringArray()" is implemented like follows:
//Converts skiplist to string array. //Note: Key-Elements of skiplist must be of type string. string ConvertSkipListKeysToStringArray(Skip sl)[] { int i_size = GetSkipListSize(sl) int i_idx = 0
string s_elements[i_size] for none in sl do{
string s_key = (string key sl) s_elements[i_idx] = s_key i_idx++ } return s_elements }
Obviously the variable "s_elements" is being handled on the stack.
I solved the problem by using the type Array instead of string[].
|